$(function () {
    selectGroupCode();
})

function selectGroupCode() {
    let data = myAjax("/group/selectGroupCode", "", "post");
    data = data.list;
    console.log(data);
    let html = '';
    for (let i = 0; i < data.length; i++) {
        html += '<tr>' +
            '<td>' + data[i].id + '</td>\n' +
            '            <td>' + data[i].groupNumber + '</td>\n' +
            '            <td>' + data[i].groupName + '</td>\n' +
            '            <td>' + data[i].leaderNumber + '</td>\n' +
            '            <td>' + data[i].leaderName + '</td>\n' +
            '            <td>' + data[i].count + '</td>\n' +
            '            <td>' + data[i].creattime + '</td>\n' +
            '            <td><span  style="color: #1E9FFF;cursor:pointer;" onclick="findGroup(\'' + data[i].groupNumber + '\')">查看</span>&nbsp;&nbsp;\n' +
            '                <span onclick="deleteGroup(\'' + data[i].groupNumber + '\')" style="color: red;cursor: pointer">删除</span></td>\n' +
            '</tr>'
    }
    $("#personnelManage").html(html);
}

function findGroup(data) {
    localStorage.setItem("ifram-groupNumber", data);
    layui.use(['transfer', 'layer', 'util', 'form'], function () {
        var $ = layui.$
            , transfer = layui.transfer
            , layer = layui.layer
            , util = layui.util
            , form = layui.form;
        layer.open({
            type: 2,
            area: ['900px', '600px'],
            fixed: false, //不固定
            maxmin: true,
            content: 'iframGroup.html'
        });
    });
}

function deleteGroup(data) {
    let data1 = {
        groupNumber:data,
    }
    let result = myAjax("/group/deleteGroup",data1,"post");
    if (result.result == 1){
        alert("删除成功");
    }else {
        alert("未知的错误发生了");
    }
    $("#body").load("group.html");
}